{% extends "base.html" %}

{% block title %}音乐大厅{% endblock %}

{% block content %}
<section class="container py-5">
  <div class="text-center mb-5">
    <h2 class="display-4">🎵 欢迎进入音乐世界</h2>
    {% if current_user.is_authenticated %}
      <a href="{{ url_for('create_playlist') }}" class="btn btn-primary btn-lg mt-3">
        <i class="bi bi-plus-circle"></i> 新建歌单
      </a>
    {% endif %}
  </div>

  {% if current_user.is_authenticated %}
  <div class="row">
    <div class="col-lg-10 mx-auto">
      <h3 class="mb-4 border-bottom pb-2">我的歌单（{{ current_user.playlists|length }}）</h3>

      <!-- 歌单展示区 -->
<!--      <div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">-->
<!--        {% for playlist in current_user.playlists %}-->
<!--        <div class="col">-->
<!--          <div class="card shadow-hover h-100">-->
<!--            <div class="card-body">-->
<!--              <h5 class="card-title">-->
<!--                <a href="{{ url_for('view_playlist', playlist_id=playlist.id) }}"-->
<!--                   class="text-decoration-none stretched-link">-->
<!--                  {{ playlist.name }}-->
<!--                </a>-->
<!--              </h5>-->
<!--              <small class="text-muted">创建于 {{ playlist.created_at.strftime('%Y-%m-%d') }}</small>-->
<!--            </div>-->
<!--          </div>-->
<!--        </div>-->
<!--        {% else %}-->
<!--        <div class="col-12">-->
<!--          <div class="alert alert-info">-->
<!--            <i class="bi bi-music-note-list"></i> 尚未创建歌单，点击上方按钮开始-->
<!--          </div>-->
<!--        </div>-->
<!--        {% endfor %}-->
<!--      </div>-->
        {% if current_user.is_authenticated %}
<!-- 新增隐私提示区块 -->
<div class="privacy-alert alert alert-info">
  <i class="bi bi-lock"></i>
  你的个人歌单已默认隐藏，<a href="{{ url_for('privacy_settings') }}">前往隐私设置</a>调整可见性
</div>

<!-- 只展示公开歌单 -->
        <section class="public-playlists">
          <h4>发现热门歌单</h4>
          <div class="row">
            {% for playlist in public_playlists %}
            <div class="col-md-3">
              <div class="card">
                <div class="card-body">
                  <a href="{{ url_for('view_playlist', playlist_id=playlist.id) }}">
                    {{ playlist.name }}
                  </a>
                  <span class="badge bg-secondary">
                    {{ playlist.user.username }}
                  </span>
                </div>
              </div>
            </div>
            {% endfor %}
          </div>
        </section>
        {% endif %}
    </div>
  </div>
  {% else %}
  <!-- 未登录展示 -->
  <div class="text-center mt-5">
    <div class="card border-0 bg-light">
      <div class="card-body py-5">
        <h3 class="card-title mb-4">发现属于你的音乐</h3>
        <p class="lead mb-4">登录后创建个性化歌单</p>
        <div class="d-flex justify-content-center gap-3">
          <a href="{{ url_for('register') }}" class="btn btn-primary px-4">立即注册</a>
          <a href="{{ url_for('login') }}" class="btn btn-outline-secondary px-4">已有账号登录</a>
        </div>
      </div>
    </div>
  </div>
  {% endif %}
</section>
{% endblock %}
